package cc.eddic.practice.spring.dto;


import cc.eddic.practice.spring.domain.Category;
import cc.eddic.practice.spring.domain.SubCategory;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.val;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CategoryResponse {
    private long id;
    private String name;
    private List<SubCategory> subCatogorires;
    private LocalDateTime createdOn;
    private LocalDateTime updatedOn;
    private Integer version;

    public static CategoryResponse from(final Category category){
        val dto=new CategoryResponse();
        BeanUtils.copyProperties(category,dto);
        return dto;
    }
}
